package cn.dengta.context.model;

import java.util.Date;
import java.util.Locale;

import cn.dengta.common.context.I18N;
import cn.dengta.common.util.Formats;
import cn.dengta.context.web.RequestContextImpl;
import cn.dengta.webapp.base.util.AppVersions;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class FreezeTip {

	String tip;

	Date freezeTime;

	String freezeTime_;

	Long userId;

	String email;

	public static FreezeTip of(WesKit wesKit, String freezeTip, Date freezeTime, Long userId) {
		FreezeTip dto = new FreezeTip();
		dto.tip = freezeTip;
		dto.freezeTime = freezeTime;
		dto.freezeTime_ = freezeTime != null ? "封禁至：" + Formats.formatDefDate(dto.freezeTime) : null;
		dto.email = WesKit.weskit_email_map.get(wesKit);
		dto.userId = userId;
		return dto;
	}

	@JSONField(serialize = false)
	public Object getExtra(String version) {
		final WesKit wesKit = RequestContextImpl.get().sessionContext().getWesKit();
		return (wesKit.isInterior() && AppVersions.gt(version, AppVersions.v_5_0_2) || !wesKit.isMain()) ? this : I18N.msg(UserI18nKey.KE_FU_CONTACT, email);
	}

	@JSONField(serialize = false)
	public Object getExtra(Locale locale) {
		return AppContext.inter() ? this : I18N.msg(UserI18nKey.KE_FU_CONTACT, email, locale);
	}

}
